package exp.day02;

//统计一篇文章中每一个字母出现的频率
public class P01 {
    public static void main(String[] args) {
        int[] num = new int[26];
        int count = 0;
        String str = "ahut2020-AndroidProgramming";
        char[] a = str.toLowerCase().toCharArray();
//        System.out.println(a);
        for (char i : a) {
            if (Character.isLowerCase(i)) {
                num[i - 97]++;
                count++;
            }
        }
        for (int i = 0; i < num.length; i++) {
            if (num[i] != 0) {
                char j = (char) (i + 97);
                System.out.println(j + " 出现频率为:" + (float) num[i] / count);
            }
        }
    }
}
